package com.myway.service.impl;

import com.myway.dao.TabQuestionAnswerMapper;
import com.myway.pojo.TabQuestionAnswer;
import com.myway.pojo.TabQuestionAnswerExample;
import com.myway.service.TabQuestionAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Zap on 2018-08-13.
 */
@Service
public class TabQuestionAnswerServiceImpl implements TabQuestionAnswerService {

    @Autowired
    private TabQuestionAnswerMapper tabQuestionAnswerMapper;

    @Override
    public List<TabQuestionAnswer> selectByTypeId(Integer typeId) {
        TabQuestionAnswerExample example = new TabQuestionAnswerExample();
        example.createCriteria().andTypeIdEqualTo(typeId);
        return tabQuestionAnswerMapper.selectByExample(example);
    }

    @Override
    public List<TabQuestionAnswer> selectAll() {
        return tabQuestionAnswerMapper.selectByExample(null);
    }

    @Override
    public void addQuestionAnswer(TabQuestionAnswer tabQuestionAnswer) {
        tabQuestionAnswerMapper.insert(tabQuestionAnswer);
    }

    @Override
    public void deleteById(Integer id) {
        tabQuestionAnswerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateQuestionAnswer(TabQuestionAnswer tabQuestionAnswer) {
        tabQuestionAnswerMapper.updateByPrimaryKey(tabQuestionAnswer);
    }
}
